import Vue from 'vue'
import VueRouter from 'vue-router'
import {routers} from './router'

Vue.use(VueRouter)

const router = new VueRouter({
  mode: 'history',
  routes:routers
})

/**
 * 路由跳转前
 */
router.beforeEach((to, from, next) => {
  if (to.meta.title)
    document.title = to.meta.title
  router.app.$options.store.dispatch('pageChange',true)
  next()
})
/**
 * 跳转后
 */
router.afterEach(() => {
  router.app.$options.store.dispatch('pageChange',false)
})

export default router
